package com.si.anddos.library.provider;

import java.io.File;
import java.net.URL;

import com.si.anddos.dpadapters.Account;
import com.si.anddos.library.main.AccountDetail;
import com.si.anddos.utils.FileSaver;

/**
 * 
 * @author Carlos Martinez
 */
//TODO rozdelit na vice casti - Upload a Download provider
public interface ServiceProvider {

	public void setServiceProviderListener(ServiceProviderListener listener);
	
	public void setFileSaver(FileSaver fileSaver);
	
	public URL getURL();
	
	/**
	 * Ask api for detail from default url in provider
	 * @return Info about file
	 * @throws ServiceProviderException
	 */
	public FileInfo getFileInfo() throws ServiceProviderException;
	
	/**
	 * Ask API for detail information about stored file.
	 * 
	 * @param url URL referencing file.
	 * @return Info about file. Null if file does not exists.
	 * @throws ServiceProviderException if something went wrong.
	 */
	public FileInfo getFileInfo(URL url) throws ServiceProviderException;
	
	/**
	 * Ask API for detail information about user account.
	 * 
	 * @param account Account with user credentials.
	 * @return Info about account. Returns null if user credentials are wrong.
	 * @throws ServiceProviderException if network comunication fails.
	 */
	public AccountDetail getAccountDetail(Account account) throws ServiceProviderException;
	
	public void download(long position) throws ServiceProviderException;
		
	public void download(Account account, long position) throws ServiceProviderException;
	
	public void stopDownload();

	public void upload(File file);
	
	public void upload(File file, String userName, String password);
	
	public void upload(File file, Account user);
	
	public void pause(boolean isLogged);
	
}
